package org.wjw.utils;

import org.wjw.model.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class UserUtil {

    public static User checkUserLoginStatus (HttpServletRequest req) {
        if (req == null) {
            return null;
        }
        // 获取session
        HttpSession session = req.getSession();
        if (session == null) {
            return null;
        }
        // 获取User对象
        User user = (User) session.getAttribute("userInfo");
        // 返回
        return user;
    }
}
